package cn.techaction.service.Impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.techaction.common.SverResponse;
import cn.techaction.dao.ActionParamDao;
import cn.techaction.pojo.ActionParam;
import cn.techaction.service.ActionParamService;

@Service
public class ActionParamServiceImpl implements ActionParamService{
	@Autowired
    private ActionParamDao aParamDao;

	@Override
	public SverResponse<List<ActionParam>> findAllParams() {
		// TODO Auto-generated method stub
		//查找一级子节点
		List<ActionParam> paramList=aParamDao.findParamByParentId(0);
		//递归查询所有子节点
		for(ActionParam param:paramList) {
			findDirectChildren(param);
		}
		return SverResponse.createRespBySuccess(paramList);
	}
    //递归查找
	private void findDirectChildren(ActionParam parentParam) {
		// TODO Auto-generated method stub
		//查找子节点
		List<ActionParam> paramList=aParamDao.findParamByParentId(parentParam.getId());
		parentParam.setClidren(paramList);
		for(ActionParam p:paramList) {
			findDirectChildren(p);
		}
	}
	

}
